******************************************************************************************************
* Replication file: 'Structural adjustment, partisan alignment, and protest in the developing world '
*
* Date: 8/12/2023
* Contact: bernhard.reinsberg@glasgow.ac.uk
******************************************************************************************************

* Data and variables
******************************************************************************

  use "JPR_replication", clear

  
* Individual-level variables

  g x_prot=pardem>=1  
  replace x_prot=. if pardem>=6
  lab var x_prot "Protest"
  
  g realprot=pardem>=1 & pardem<=3  
  replace realprot=. if pardem>=6
  lab var realprot "Protest behavior"
	
  g sap_worse=(sapsat==1|sapsat==2)
  lab var sap_worse "SAP made my life worse"
  replace sap_worse=. if sapsat>=6
  
  g sap_bad=(sapmin==3|sapmin==4)
  lab var sap_bad "SAP worse for people"
  replace sap_bad=. if sapmin>=6
  
  g PID=1*(pidwin==1)+2*(pidwin==0)+3*(pidwin==2)  
  replace PID=. if pidwin>3
  lab var PID "3=win, 1=neutral, 2=lose"
  g PIDO=3-PID
  replace PIDO=. if pidwin==1
  lab var PIDO "Opposition supporter"
  
  g psj=occup==9|occup==10|occup==17|occup==20|occup==56
  lab var psj "Public-sector job"
  g x_supdem=(supdem==1)  
  lab var x_supdem "Democracy supporter"
  g x_spubsec=(sparet==1|sparet==2)
  lab var x_spub "Public sector support"
  g x_govfew=(pfrall==1|pfrall==2)
  lab var x_govfew "Government is run for the few"
  g x_pf=(pfgpre==1|pfgpre==2)
  lab var x_pf "President performance: Dissatisfied"
  g x_sateco=(pfenow==4|pfenow==5)
  lab var x_sateco "Satisfied with economy now"
  g x_pf_own=(pfeerd==1|pfeerd==2)
  lab var x_pf_own "Own living conditions: Worse than others"
  g x_pf_past=(pfepas==1|pfepas==2)
  lab var x_pf_past "Economic conditions: Worse than one year ago"
  g x_pf_fut=(pfefut==1|pfefut==2)
  lab var x_pf_fut "Future economy: Expect to be worse"
  g x_eth_now=(pfrfai==1|pfrfai==2)
  lab var x_eth_now "Identity group treated unfairly"
  g x_assn=(pfrass==1|pfrass==2)
  lab var x_assn "Freedom of association: Worse now than 1 year"
  g x_eq=(pfreq==1|pfreq==2)
  lab var x_eq "Inequality: Worse now than 1 year"

  g x_unemp=occup==0  
  replace x_unemp=1 if unemp==1 & x_unemp==0  
  lab var x_unemp "Unemployed"
  g x_male=gender==1
  lab var x_male "Male"
  replace age=. if age>100 | age==0
  g lnage=ln(age)
  lab var lnage "Age (logged)"
  g x_educ=(educ==3|educ==2)  
  lab var x_educ "Educated"  
  g x_urb=urbrur==1
  lab var x_urb "Urban"
  
  g x_radio=medrad==5|medrad==6
  replace x_radio=medrad==4|medrad==5  
  lab var x_radio "Radio listener"
  g x_intpol=scint==1
  lab var x_intpol "Politically interested"
  g x_knowfm=sckfin==2
  replace x_knowfm=sckfin==1  
  lab var x_knowfm "Politically knowledgeable"
    
  g knwsap=sapknw==2	
  replace knwsap=sapknw==1  
  lab var knwsap "Heard about IMF SAP"
  
  g x_nofood=povfoo>0  
  replace x_nofood=. if povfoo>=5
  g x_nowat=povwat>0
  replace x_nowat=. if povwat>=5
  g x_nohth=povhth>0
  replace x_nohth=. if povhth>=5
  g x_noinc=povinc>0
  replace x_noinc=. if povinc>=5
  foreach x in povfoo povwat povhth povinc{
   g X`x'=`x'
   replace X`x'=. if `x'>=5
   }
  egen poverty=rowtotal(Xpov*)
  replace poverty=. if Xpovfo==.|Xpovwat==.|Xpovinc==.|Xpovhth==.
  lab var poverty "Deprivation index"

  
* Meso-level variables 

  g anyexcl=excluded>0
  lab var anyexcl "Any excluded group"
  g lnttime=ln(ttime)
  lab var lnttime "Logged travel time"
    
	
* Country-level variables

  g ba2lab=BA2LAB>0	
  lab var ba2lab "Public-sectpor conditionality"
	
	
* Plots 
*******************************************************************************	

  g PID3=2*PIDO
  replace PID3=1 if PID==1


* Dissatisfication with SAP and Protest (Figure 1)

  graph bar x_prot if knwsap==1, over(sap_w, relabel(1 "IMF SAP did not made my life worse" 2 "IMF SAP made my life worse")) scheme(s1mono) ytitle(Protest)

  
* Partisan difference in protest under IMF programs  (Figure 2)

  graph bar x_prot if knwsap==1, by(IMFnn, note(" ")) over(PID3, relabel(1 "Government supporters"  2 "Non-partisans" 3 "Opposition supporters")) scheme(s1mono) ytitle(Protest)
    tab iso3 if knwsap==1 & IMFnn==0
    tab iso3 if knwsap==1 & IMFnn==1
  
  
* Public-sctor conditions (Figure 3)
  
  graph bar x_prot if IMFnn==1 & knwsap==1, by(ba2lab, note(" ")) over(PID3, relabel(1 "Government supporters" 2 "Non-partisans" 3 "Opposition supporters")) scheme(s1mono) ytitle(Protest)
    ttest x_prot if knwsap==1 & IMFnn==1 & ba2lab==0, by(PIDO) une
    ttest x_prot if knwsap==1 & IMFnn==1 & ba2lab==1, by(PIDO) une
    tab iso3 if knwsap==1 & IMFnn==1 & ba2lab==0
    tab iso3 if knwsap==1 & IMFnn==1 & ba2lab==1
  
  
* Main results
******************************************************************************

* Descriptive statistics (Table A2)
 
  global X  x_male lnage x_urb x_unemp x_educ  x_supdem x_intpol x_knowfm 
  global P  x_pf x_pf_past x_govfew x_spubsec x_eq x_assn

  global Prio1 mountain lnttime urban anyexcl
  global Prio2 $Prio1 drug gem diamprim
  global Gdl1 gdl_mru gdl_wemp gdl_pipe
  global Gdl2 $Gdl1 gdl_pop gdl_iwi gdl_gini
  
  qui estpost su x_prot realprot poverty PID IMFnn ba2lab $X $P sap_w sap_b knwsap 
  esttab ., cells("count(fmt(0)) mean(fmt(3)) sd(fmt(3)) min(fmt(3)) max(fmt(3))")
    

* Main effect for IMF programs (Table 1)	
	
  mat F=J(2,3,0)
  
  qui areg x_prot i.PID##IMFnn [aw=afcombwt], a(country) ro
  est store a11
  mat F[1,1]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##IMFnn $X [aw=afcombwt], a(country) ro
  est store a12
  mat F[1,2]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##IMFnn $X $P [aw=afcombwt], a(country) ro
  est store a13
  mat F[1,3]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,3]=r(p)/2

  estout a1*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.IMFnn _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F 

  qui cmp setup 
  qui xi:reg x_prot i.country
  g INTIMF=PIDO*IMFnn
  qui cmp (x_prot=PIDO INTIMF IMFnn $X $P _Icountry*), indicators(1) ro 
  margins, at(PIDO=0 INT=0 IMFnn=1) vce(uncond)
  margins, at(PIDO=1 INT=1 IMFnn=1) vce(uncond)
  margins, at(PIDO=(0 1) INT=0 IMFnn=0) vce(uncond)
  
  
* Main effect for public-sector conditionality  (Table 2)
  
  qui areg x_prot i.PID##ba2lab [aw=afcombwt] if IMFnn>0, a(country) ro 
  est store a21
  mat F[1,1]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##ba2lab $X [aw=afcombwt] if IMFnn>0, a(country) ro
  est store a22
  mat F[1,2]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##ba2lab $X $P [aw=afcombwt] if IMFnn>0, a(country) ro
  est store a23
  mat F[1,3]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,3]=r(p)/2
  
  estout a2*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F
  
  qui cmp setup 
  qui xi:reg x_prot i.country
  g INT=PIDO*ba2lab 
  qui cmp (x_prot=PIDO INT ba2lab $X $P _Icountry*) if IMFnn>0, indicators(1) ro difficult 
  margins if IMFnn>0, at(PIDO=0 INT=0 ba2lab=1) vce(uncond)
  margins if IMFnn>0, at(PIDO=1 INT=1 ba2lab=1) vce(uncond)
  margins if IMFnn>0, at(PIDO=(0 1) INT=0 ba2lab=0) vce(uncond)

  
* Robustness tests 
*******************************************************************************  

* Protest behavior (Table A3) 

  qui areg realprot i.PID##ba2lab [aw=afcombwt] if IMFnn>0, a(country) ro 
  est store b11
  mat F[1,1]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,1]=r(p)/2
  qui areg realprot i.PID##ba2lab $X [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b12
  mat F[1,2]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,2]=r(p)/2
  qui areg realprot i.PID##ba2lab $X $P [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b13
  mat F[1,3]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,3]=r(p)/2
  
  estout b1*, title("Protest behavior") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F


* Simpler comparison (dropping non-partisans) (Table A4) 

  qui areg x_prot i.PIDO##ba2lab [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b21
  qui areg x_prot i.PIDO##ba2lab $X [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b22
  qui areg x_prot i.PIDO##ba2lab $X $P [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b23
  
  estout b2*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* ) stats(N r2, fmt(0 3))  


* Five-year horizon (Table A5)

  g IMF5=IMFnn
  replace IMF5=1 if iso3=="LSO"
   
  qui areg x_prot i.PID##IMF5 [aw=afcombwt], a(country) ro
  est store b31
  mat F[1,1]=_b[2.PID#1.IMF5]-_b[3.PID#1.IMF5]
  qui test (2.PID#1.IMF5=3.PID#1.IMF5)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##IMF5 $X [aw=afcombwt], a(country) ro
  est store b32
  mat F[1,2]=_b[2.PID#1.IMF5]-_b[3.PID#1.IMF5]
  qui test (2.PID#1.IMF5=3.PID#1.IMF5)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##IMF5 $X $P [aw=afcombwt], a(country) ro
  est store b33
  mat F[1,3]=_b[2.PID#1.IMF5]-_b[3.PID#1.IMF5]
  qui test (2.PID#1.IMF5=3.PID#1.IMF5)
  mat F[2,3]=r(p)/2
  
  estout b3*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.IMF5 _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F 

  
* IMF exposure (Table A6)

  qui areg x_prot i.PID##c.imf85 [aw=afcombwt], a(country) ro
  est store b41
  mat F[1,1]=_b[2.PID#imf85]-_b[3.PID#imf85]
  qui test (2.PID#imf85=3.PID#imf85)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##c.imf85 $X [aw=afcombwt], a(country) ro
  est store b42
  mat F[1,2]=_b[2.PID#imf85]-_b[3.PID#imf85]
  qui test (2.PID#imf85=3.PID#imf85)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##c.imf85 $X $P [aw=afcombwt], a(country) ro
  est store b43
  mat F[1,3]=_b[2.PID#imf85]-_b[3.PID#imf85]
  qui test (2.PID#imf85=3.PID#imf85)
  mat F[2,3]=r(p)/2
  
  estout b4*, title("Deprivation index") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(imf85* _cons  1.P*) stats(N r2, fmt(0 3))  
  mat li F 


* Number of labor conditions  (Table A7)

  g lnba2lab=ln(1+BA2LAB)
  qui areg x_prot i.PID##c.lnba2lab [aw=afcombwt] if IMFnn>0, a(country) ro 
  est store b51
  mat F[1,1]=_b[2.PID#lnba2lab]-_b[3.PID#lnba2lab]
  qui test (2.PID#lnba2lab=3.PID#lnba2lab)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##c.lnba2lab $X [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b52
  mat F[1,2]=_b[2.PID#lnba2lab]-_b[3.PID#lnba2lab]
  qui test (2.PID#lnba2lab=3.PID#lnba2lab)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##c.lnba2lab $X $P [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b53
  mat F[1,3]=_b[2.PID#lnba2lab]-_b[3.PID#lnba2lab]
  qui test (2.PID#lnba2lab=3.PID#lnba2lab)
  mat F[2,3]=r(p)/2
  
  estout b5*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(ln* _cons 1.P*) stats(N r2, fmt(0 3))  
  mat li F


* Waiver-corrected conditions  (Table A8)

  qui areg x_prot i.PID##cbalab [aw=afcombwt] if IMFnn>0, a(country) ro 
  est store b61
  mat F[1,1]=_b[2.PID#1.cbalab]-_b[3.PID#1.cbalab]
  qui test (2.PID#1.cbalab=3.PID#1.cbalab)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##cbalab $X [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b62
  mat F[1,2]=_b[2.PID#1.cbalab]-_b[3.PID#1.cbalab]
  qui test (2.PID#1.cbalab=3.PID#1.cbalab)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##cbalab $X $P [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b63
  mat F[1,3]=_b[2.PID#1.cbalab]-_b[3.PID#1.cbalab]
  qui test (2.PID#1.cbalab=3.PID#1.cbalab)
  mat F[2,3]=r(p)/2
  
  estout b6*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.cbalab _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F


* Clustered SE (Table A9) 

  qui areg x_prot i.PID##ba2lab [aw=afcombwt] if IMFnn>0, a(country) ro cl(country)
  est store b71
  mat F[1,1]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##ba2lab $X [aw=afcombwt] if IMFnn>0, a(country) ro cl(country)
  est store b72
  mat F[1,2]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##ba2lab $X $P [aw=afcombwt] if IMFnn>0, a(country) ro cl(country)
  est store b73
  mat F[1,3]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,3]=r(p)/2
  
  estout b7*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F 
  
  qui cmp (x_prot=PIDO INT ba2lab $X $P _Icountry*) if IMFnn>0, indicators(1) ro cl(country) difficult 
  margins if IMFnn>0, at(PIDO=0 INT=0 ba2lab=1) vce(uncond)
  margins if IMFnn>0, at(PIDO=1 INT=1 ba2lab=1) vce(uncond)
  margins if IMFnn>0, at(PIDO=(0 1) INT=0 ba2lab=0) vce(uncond)


* Pooled analysis (Table A10)

  qui reg x_prot i.PID##ba2lab if IMFnn>0 [aw=afcombwt], ro
  est store b81
  mat F[1,1]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,1]=r(p)/2
  qui reg x_prot i.PID##ba2lab $X if IMFnn>0 [aw=afcombwt], ro
  est store b82
  mat F[1,2]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,2]=r(p)/2
  qui reg x_prot i.PID##ba2lab $X $P if IMFnn>0 [aw=afcombwt], ro
  est store b83
  mat F[1,3]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,3]=r(p)/2
  
  estout b8*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F 
  margins ba2lab#PID if IMFnn>0, vce(uncond)
    

* Interaction with IMF awareness (Table A11) 

  qui areg x_prot i.PID##ba2lab i.PID##knwsap [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b91
  mat F[1,1]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##ba2lab i.PID##knwsap $X [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b92
  mat F[1,2]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##ba2lab i.PID##knwsap $X $P [aw=afcombwt] if IMFnn>0, a(country) ro
  est store b93
  mat F[1,3]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,3]=r(p)/2

  estout b9*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F
  

* Interaction with corruption (Table A12)

  g x_corr=(pfpcr2>=1 & pfpcr2<=2)
  replace x_corr=. if pfpcr2>=7
 
  qui areg x_prot i.PID##ba2lab i.PID##x_corr [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c11
  mat F[1,1]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##ba2lab i.PID##x_corr $X [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c12
  mat F[1,2]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##ba2lab i.PID##x_corr $X $P [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c13
  mat F[1,3]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,3]=r(p)/2

  estout c1*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F


* Controlling for SAPBAD (Table A13)   

  qui areg x_prot i.PID##ba2lab sap_bad [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c21
  mat F[1,1]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##ba2lab sap_bad $X [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c22
  mat F[1,2]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##ba2lab sap_bad $X $P [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c23
  mat F[1,3]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,3]=r(p)/2

  estout c2*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F    


* Controlling for other reforms (Table A14)

  g NBA2LAB=BA2TOT-BA2LAB
  g lnNBA2LAB=ln(1+NBA2LAB)
  
  qui areg x_prot i.PID##ba2lab i.PID##c.lnNBA2LAB [aw=afcombwt] if IMFnn>0, a(country) ro 
  est store c31
  mat F[1,1]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##ba2lab i.PID##c.lnNBA2LAB $X [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c32
  mat F[1,2]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##ba2lab i.PID##c.lnNBA2LAB $X $P [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c33
  mat F[1,3]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,3]=r(p)/2

  estout c3*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* 1.P* lnNBA2LAB) stats(N r2, fmt(0 3))  
  mat li F
  
  
* IMF program regression with subnational controls - baseline set (Table A15)
  
  qui areg x_prot i.PID##IMFnn $X $Gdl1 [aw=afcombwt], a(country) ro
  est store c41
  mat F[1,1]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##IMFnn $X $Prio1 [aw=afcombwt], a(country) ro
  est store c42
  mat F[1,2]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##IMFnn $X $Prio1 $Gdl1 [aw=afcombwt], a(country) ro
  est store c43
  mat F[1,3]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,3]=r(p)/2
  
  estout c4*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.IMFnn _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F 

  
* IMF program regression with subnational controls - extended set (Table A16)

  qui areg x_prot i.PID##IMFnn $X $Gdl2 [aw=afcombwt], a(country) ro
  est store c51
  mat F[1,1]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##IMFnn $X $Prio2 [aw=afcombwt], a(country) ro
  est store c52
  mat F[1,2]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##IMFnn $X $Prio2 $Gdl2 [aw=afcombwt], a(country) ro
  est store c53
  mat F[1,3]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,3]=r(p)/2

  estout c5*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.IMFnn _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F 


* IMF conditionality regression with subnational controls - baseline set (Table A17)

  qui areg x_prot i.PID##ba2lab $X $Gdl1 [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c61
  mat F[1,1]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##ba2lab $X $Prio1 [aw=afcombwt] if IMFnn>0, a(country) ro 
  est store c62
  mat F[1,2]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##ba2lab $X $Prio1 $Gdl1 [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c63
  mat F[1,3]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,3]=r(p)/2

  estout c6*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F


* IMF conditionality regression with subnational controls - extended set (Table A18)

  qui areg x_prot i.PID##ba2lab $X $Gdl2 [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c71
  mat F[1,1]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,1]=r(p)/2
  qui areg x_prot i.PID##ba2lab $X $Prio2 [aw=afcombwt] if IMFnn>0, a(country) ro 
  est store c72
  mat F[1,2]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,2]=r(p)/2
  qui areg x_prot i.PID##ba2lab $X $Prio2 $Gdl2 [aw=afcombwt] if IMFnn>0, a(country) ro
  est store c73
  mat F[1,3]=_b[2.PID#1.ba2lab]-_b[3.PID#1.ba2lab]
  qui test (2.PID#1.ba2lab=3.PID#1.ba2lab)
  mat F[2,3]=r(p)/2

  estout c7*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F
  
  
* Multi-level model - baseline controls (Table A19)

  mixed x_prot PID##IMFnn $X $Gdl1 $Prio1 [fw=afcombwt] || country:, || GDLCODE:,
  est store c81
   estat group
   estat icc
  mixed x_prot PID##IMFnn $X $Gdl1 $Prio1 [fw=afcombwt] || country:, || GDLCODE:, || gid:, 
  est store c82
   estat group
   estat icc
  mixed x_prot PID##ba2lab $X $Gdl1 $Prio1 [fw=afcombwt] if IMFnn>0 || country:, || GDLCODE:,
  est store c83
   estat group
   estat icc
  mixed x_prot PID##ba2lab $X $Gdl1 $Prio1 [fw=afcombwt] if IMFnn>0 || country:, || GDLCODE:, || gid:, 
  est store c84
   estat group
   estat icc

  estout c8*, title("Protest") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.ba2lab _cons *0.* 1.P*) stats(N r2, fmt(0 3))  


* General deprivation (Table A20)

  qui areg poverty i.PID##IMFnn [aw=afcombwt], a(country) ro
  est store c91
  mat F[1,1]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,1]=r(p)/2
  qui areg poverty i.PID##IMFnn $X [aw=afcombwt], a(country) ro
  est store c92
  mat F[1,2]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,2]=r(p)/2
  qui areg poverty i.PID##IMFnn $X $P [aw=afcombwt], a(country) ro
  est store c93
  mat F[1,3]=_b[2.PID#1.IMFnn]-_b[3.PID#1.IMFnn]
  qui test (2.PID#1.IMFnn=3.PID#1.IMFnn)
  mat F[2,3]=r(p)/2

  estout c9*, title("Deprivation index") note("p-values: ⁺ 10%  * 5%  ** 1%") starlevels(⁺ .1 * .05 ** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(1.IMFnn _cons *0.* 1.P*) stats(N r2, fmt(0 3))  
  mat li F    

  qui cmp (poverty=PIDO INTIMF IMFnn $X $P _Icountry*), indicators(1) ro 
  margins, at(PIDO=0 INTIMF=0 IMF=1) vce(uncond)
  margins, at(PIDO=1 INTIMF=1 IMF=1) vce(uncond)
  margins, at(PIDO=(0 1) INTIMF=0 IMF=0) vce(uncond)

  
** end of file **  
